﻿<UserControl x:Class="ProductManager.WPF.Presentation.Views.ProductListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:c="clr-namespace:ProductManager.WPF.Presentation.Converters"
             xmlns:p="clr-namespace:ProductManager.WPF.Presentation.Properties"
             xmlns:vm="clr-namespace:ProductManager.WPF.Applications.ViewModels;assembly=ProductManager.WPF.Applications"
             xmlns:util="clr-namespace:ProductManager.WPF.Presentation.Util"
             mc:Ignorable="d" d:DataContext="{d:DesignData Source=../DesignData/SampleProductListViewModel.xaml}"
             d:DesignWidth="400" d:DesignHeight="450" Loaded="UserControl_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ToolBarTray Name="ToolBarTray" DockPanel.Dock="Top" Grid.Row="0">
            <ToolBar Name="ToolBar">
                <Button Name="AddNewButton" Command="{Binding AddNewCommand}" Content="{x:Static p:Resources.Add}"/>
                <Button Name="RemoveButton" Command="{Binding RemoveCommand}" Content="{x:Static p:Resources.Remove}"/>
            </ToolBar>
            <ToolBar Name="FilterToolBar">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Label Content="Color Filter:" />
                    <!--<ComboBox Name="FilterComboBox" ItemsSource="{Binding Source={StaticResource ProductColorFilterValues}}" SelectedItem="{Binding ColorFilter}"-->
                    <ComboBox Name="FilterComboBox" ItemsSource="{Binding Source={StaticResource ProductColorFilterValues}}"
                              Width="100" HorizontalAlignment="Right" util:ComboBoxFilter.Command="{Binding FilterColorCommand}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={x:Static c:ProductColorToStringConverter.Default}}"/>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                </StackPanel>
            </ToolBar>
        </ToolBarTray>
        <ListView Grid.Row="1"  ItemsSource="{Binding Products}" SelectedItem="{Binding SelectedProduct}"
                  SelectionChanged="ListViewSelectionChanged"
                  util:GridViewSort.Command="{Binding SortCommand}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Width="25">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <ContentControl Style="{DynamicResource ChangeMarker}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding ProductID}" Header="{x:Static p:Resources.ID}" Width="40" />
                        <GridViewColumn DisplayMemberBinding="{Binding Name}" Header="{x:Static p:Resources.Name}" Width="170" />
                        <GridViewColumn DisplayMemberBinding="{Binding Color}" Header="{x:Static p:Resources.Color}" Width="70" />
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
        <Grid Grid.Row="2" Margin="0,3,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0">
                <Label Content="{x:Static p:Resources.NumberOfItems}" />
                <Label Content="{Binding TotalNumberOfProducts}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="2">
                <Button Content="&lt;&lt;" Command="{Binding FirstPageCommand}" Width="25" Height="20" />
                <Button Content="&lt;" Command="{Binding PreviousPageCommand}" Width="25" Height="20" Margin="2,0,5,0" />

                <!--<Label Content="{Binding PageNumber}" />-->
                <TextBox Text="{Binding PageNumber}" Width="30" Height="20" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
                <Label Content="of" Margin="-3,0,-3,0" />
                <Label Content="{Binding NumberOfPages}" />

                <Button Content="&gt;" Command="{Binding NextPageCommand}" Width="25" Height="20" Margin="5,0,2,0" />
                <Button Content="&gt;&gt;" Command="{Binding LastPageCommand}" Width="25" Height="20" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
